<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
		<!-- Google Chrome Frame也可以让IE用上Chrome的引擎: -->
		<meta name="renderer" content="webkit">
		<!--国产浏览器高速模式-->
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="author" content="穷在闹市" />
		<!-- 作者 -->
		<meta name="revised" content="穷在闹市.v3, 2019/05/01" />
		<!-- 定义页面的最新版本 -->
		<meta name="description" content="网站简介" />
		<!-- 网站简介 -->
		<meta name="keywords" content="搜索关键字，以半角英文逗号隔开" />
		<title>穷在闹市出品</title>

		<!-- 公共样式 开始 -->
		<link rel="stylesheet" type="text/css" href="DRadmin../../css/base.css">
		<link rel="stylesheet" type="text/css" href="DRadmin../../css/iconfont.css">
		<script type="text/javascript" src="DRadmin../../framework/jquery-1.11.3.min.js"></script>
		<link rel="stylesheet" type="text/css" href="DRadmin../../layui/css/layui.css">
		<script type="text/javascript" src="DRadmin../../layui/layui.js"></script>
		<!-- 滚动条插件 -->
		<link rel="stylesheet" type="text/css" href="DRadmin../../css/jquery.mCustomScrollbar.css">
		<script src="DRadmin../../framework/jquery-ui-1.10.4.min.js"></script>
		<script src="DRadmin../../framework/jquery.mousewheel.min.js"></script>
		<script src="DRadmin../../framework/jquery.mCustomScrollbar.min.js"></script>
		<script src="DRadmin../../jquery.mCustomScrollbar.min.js../../framework/cframe.js"></script><!-- 仅供所有子页面使用 -->
		<!-- 公共样式 结束 -->
		
		<style>
			.layui-form-label{
				width: 100px;
			}
			.layui-input-block{
				margin-left: 130px;
			}
		</style>

	</head>

	<body>
		<div  style="height: 500px;">
				<form id="addForm" class="layui-form" >
				<input type="hidden" name="nid" value="${news.addressId}">
				<div class="layui-form-item">
					<label class="layui-form-label">收货人姓名</label>
					<div class="layui-input-block">
						<input type="text"  value="${news.addName}" name="newsContext" required lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">地区</label>
					<div class="layui-input-block">
						<input type="text"  value="${news.addArea}" name="createDate" required lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">详细地区</label>
					<div class="layui-input-block">
						<input type="password"  value="${news.add}" name="dizhi" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">联系方式</label>
					<div class="layui-input-block">
						<input type="password"  value="${news.phone}" name="eamil" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">是否是默认地址</label>
					<div class="layui-input-block">
						<input type="radio" name="sfpfsp" value="dui" title="是">
						<input type="radio" name="sfpfsp" value="cuo" title="否" checked>
					</div>
				</div>
				
				<div class="layui-form-item">
					<div class="layui-input-block">
						<input class="layui-btn" lay-submit lay-filter="submitBut" type="submit" value="提交">
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
			
			
		<script>
			layui.use(['upload','form'], function() {
				var form = layui.form;
				var upload = layui.upload;
				var layer = layui.layer;
				//监听提交
				//解决了layui.open弹窗从内部关闭这个弹窗的问题
				form.on('submit(submitBut)', function(data) {
					var bo=true;
					if($('input:radio[name="sfpfsp"]:checked').val()){
							bo=true;
					}else{
						bo=false;
					}
					$.ajax({					
						url:'${pageContext.request.contextPath}/RoomAddressServlet',
						data:{
							'nid':$("input[name='nid']").val(),
							"newsContext":$("input[name='newsContext']").val(),
							"createDate":$("input[name='createDate']").val(),
							"dizhi":$("input[name='dizhi']").val(),
							"eamil":$("input[name='eamil']").val(),
							"sfpfsp":bo,
							'action':'cupdate'
						},      
						type:'post',
						dataType:'json',
						success:function(data){
							if(data.code=='0'){
								var updateFrame = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
								parent.layer.close(updateFrame);  //再改变当前层的标题
								parent.mytable.reload();
							}
						}
						
					});

				});
				
				
				
				form.verify({
					//数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
				  	ZHCheck: [
					    /^[\u0391-\uFFE5]+$/
					    ,'只允许输入中文'
				  	] 
				});
				//拖拽上传
				upload.render({
					elem: '#goodsPic',
					url: '/upload/',
					done: function(res) {
					  	console.log(res)
					}
				});
			});
		</script>

		</div>
	</body>

</html>